added some development tools
[windows-sources.git] / developer / Samples / NET Standard / ParallelExtensionsExtras_Standard / Extensions / TaskFactoryExtensions / TaskFactoryExtensions_ContinueWhenAllAny.cs
blobdf8cafd85de9eb1b009eac8300eafd6c647f8dad
1 //--------------------------------------------------------------------------
2 //
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 //
5 // File: TaskFactoryExtensions_ContinueWhenAllAny.cs
6 //
7 //--------------------------------------------------------------------------
9 using System.Collections.Generic;
11 namespace System.Threading.Tasks
13 public static partial class TaskFactoryExtensions
15 /// <summary>
16 /// Creates a continuation Task that will compplete upon
17 /// the completion of a set of provided Tasks.
18 /// </summary>
19 /// <param name="factory">The TaskFactory to use to create the continuation task.</param>
20 /// <param name="tasks">The array of tasks from which to continue.</param>
21 /// <returns>A task that, when completed, will return the array of completed tasks.</returns>
22 public static Task<Task[]> WhenAll(
23 this TaskFactory factory, params Task[] tasks)
25 return factory.ContinueWhenAll(tasks, completedTasks => completedTasks);
28 /// <summary>
29 /// Creates a continuation Task that will compplete upon
30 /// the completion of a set of provided Tasks.
31 /// </summary>
32 /// <param name="factory">The TaskFactory to use to create the continuation task.</param>
33 /// <param name="tasks">The array of tasks from which to continue.</param>
34 /// <returns>A task that, when completed, will return the array of completed tasks.</returns>
35 public static Task<Task<TAntecedentResult>[]> WhenAll<TAntecedentResult>(
36 this TaskFactory factory, params Task<TAntecedentResult>[] tasks)
38 return factory.ContinueWhenAll(tasks, completedTasks => completedTasks);
41 /// <summary>
42 /// Creates a continuation Task that will complete upon
43 /// the completion of any one of a set of provided Tasks.
44 /// </summary>
45 /// <param name="factory">The TaskFactory to use to create the continuation task.</param>
46 /// <param name="tasks">The array of tasks from which to continue.</param>
47 /// <returns>A task that, when completed, will return the completed task.</returns>
48 public static Task<Task> WhenAny(
49 this TaskFactory factory, params Task[] tasks)
51 return factory.ContinueWhenAny(tasks, completedTask => completedTask);
54 /// <summary>
55 /// Creates a continuation Task that will complete upon
56 /// the completion of any one of a set of provided Tasks.
57 /// </summary>
58 /// <param name="factory">The TaskFactory to use to create the continuation task.</param>
59 /// <param name="tasks">The array of tasks from which to continue.</param>
60 /// <returns>A task that, when completed, will return the completed task.</returns>
61 public static Task<Task<TAntecedentResult>> WhenAny<TAntecedentResult>(
62 this TaskFactory factory, params Task<TAntecedentResult>[] tasks)
64 return factory.ContinueWhenAny(tasks, completedTask => completedTask);